<template>
	<view>
		<u-calendar v-bind="$attrs" :mode="mode" :defaultDate="defaultDate" :maxDate="maxDate" :minDate="minDate"
			@confirm="onConfirm" @close="onClose" :monthNum="monthNum"></u-calendar>
	</view>
</template>

<script>
	export default {
		name: "cg-calendar",
		props: {
			mode: {
				default: 'range',
				type: String
			},
			maxDate: {
				default: new Date().getTime(),
				type: Number
			},

			minDate: {
				default: new Date().getTime() - 1000 * 3600 * 24 * 90,
				type: Number
			},
			defaultDate: {
				defaultDateMultiple: uni.$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd'),

				type: Array | String | Number
			},
			monthNum: {
				default: 4,
				type: Number
			},
		},
		data() {
			return {

			};
		},
		methods: {
			onConfirm(e) {
				const start = e[0];
				const end = e[e.length - 1];
				const date = [start, end]
				this.$emit('confirm', date, e)
			},
			onClose() {
				this.$emit('close', false)
			}
		}
	}
</script>

<style>

</style>